package com.winning.joiner.magiccube.common.dto;

import java.util.List;

import com.github.pagehelper.PageInfo;


public class ResponseModel {
	/**
	 * 消息类型：成功
	 */
	public final static String MSGTYPE_SUCCESS = "success";
	/**
	 * 消息类型：危险
	 */
	public final static String MSGTYPE_DANGER = "danger";
	/**
	 * 消息类型：提示
	 */
	public final static String MSGTYPE_INFO="info";
	/**
	 * 消息类型：警告
	 */
	public final static String MSGTYPE_WARINNING="warning";
	/**
	 * 状态：0 成功
	 */
	public final static Integer STATUS_SUCCESS=0;
	/**
	 * 消息类型：1 错误
	 */
	public final static Integer STATUS_FAIL=1;
	/**
	 * 消息类型：2 失败
	 */
	public final static Integer STATUS_ERROR=2;
	/**
	 * 消息类型：3 权限不足
	 */
	public final static Integer STATUS_PERMISSION_DENIED=3;
	/**
	 * 消息类型：4 认证失败
	 */
	public final static Integer STATUS_AUTH_FAILED=4;


	/**
	 * 返回状态：判断返回的操作是否成功 标准值：0-处理正常,1-处理失败,2-后台出错,3-权限不足,4-认证失败
	 */
	private Integer status;
	
	/**
	 * 为了兼容ry
	 */
	private Integer code;
	private String msg;

	/**
	 * 返回自定义单个实体
	 */
	private Object data;

	/**
	 * 返回自定义多个实体 
	 */
	private List<?> datas;
	
	/** 分页用：总记录数 */
    private long total;
    
    /** 分页用：列表数据 */
    private List<?> rows;


	/**
	 * 属于组件:msg_box 作用： 标准值：danger,info,success,warning 
	 */
	private String msgType;

	/**
	 * 属于组件:msg_box 作用：小型msgbox的主要文字,大型的上行文字 
	 */
	private String msgContent;
	/**
	 * 
	 * 属于组件:msg_box 作用：大型msgbox的下行文字 
	 */
	private String msgDetail;
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public List<?> getDatas() {
		return datas;
	}
	public void setDatas(List<?> datas) {
		this.datas = datas;
	}
	public String getMsgType() {
		return msgType;
	}
	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}
	public String getMsgContent() {
		return msgContent;
	}
	public void setMsgContent(String msgContent) {
		this.msgContent = msgContent;
	}
	public String getMsgDetail() {
		return msgDetail;
	}
	public void setMsgDetail(String msgDetail) {
		this.msgDetail = msgDetail;
	}
	
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public long getTotal() {
		return total;
	}
	public void setTotal(long total) {
		this.total = total;
	}
	public List<?> getRows() {
		return rows;
	}
	public void setRows(List<?> rows) {
		this.rows = rows;
	}
	/**
	 * 空构造
	 */
	public ResponseModel() {
		super();
	}
	/**
	 * 简单信息提示
	 */
	public ResponseModel(Integer status,String  msgType,String msgContent) {
		 this.status=status;
		 this.msgType=msgType;
		 this.msgContent=msgContent;
		 this.code=status;
		 this.msg=msgContent;
	}
	
	/**
	 * 简单信息提示
	 */
	public ResponseModel(Integer status,String  msgType,String msgContent,Object data,List<?> datas) {
		 this.status=status;
		 this.msgType=msgType;
		 this.msgContent=msgContent;
		 this.data=data;
		 this.datas=datas;
		 this.code=status;
		 this.msg=msgContent;
	}
	/**
	 * 简单返回数据
	 * @param list
	 * @return
	 */
	public static ResponseModel success() {
		ResponseModel responseModel=new ResponseModel(STATUS_SUCCESS,null,"sucess");
		return responseModel;
	}
	/**
	 * 简单返回数据
	 * @param list
	 * @return
	 */
	public static ResponseModel success(List<?> list) {
		ResponseModel responseModel=new ResponseModel(STATUS_SUCCESS,null,null,null,list);
		return responseModel;
	}
	/**
	 * 简单成功
	 * @param data
	 * @return
	 */
	public static ResponseModel success(Object data) {
		ResponseModel responseModel=new ResponseModel(STATUS_SUCCESS,null,null,data,null);
		return responseModel;
	}
	/**
	 * 失败信息
	 * @param msgContent
	 * @return
	 */
	public static ResponseModel fail(String msgContent){
		return new ResponseModel(STATUS_FAIL, MSGTYPE_DANGER, msgContent);
	}
	
	public static ResponseModel authFail(String msgContent){
		return new ResponseModel(STATUS_AUTH_FAILED, MSGTYPE_WARINNING, msgContent);
	}
	
	public static ResponseModel error(String msgContent){
		return new ResponseModel(STATUS_ERROR, MSGTYPE_DANGER, msgContent);
	}
	
	/**
	 * 分页信息
	 * @param list
	 * @return
	 */
	public static ResponseModel successPage(List<?> rows) {
		ResponseModel responseModel=new ResponseModel();
		responseModel.setRows(rows);
		PageInfo<?> pageInfo=new PageInfo<>(rows);
		responseModel.setTotal(pageInfo.getTotal());
		responseModel.setStatus(STATUS_SUCCESS);
		return responseModel;
	}





}
